package fr.web325.servlet.client.register;

import fr.web325.dao.UserDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/shop/client/activation")
public class Activation extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取激活码
        String code = req.getParameter("ActivationCode");
        // 控制Dao激活用户
        try {
            if(new UserDao().editUserStatus(code)){
                // 激活成功 跳转登录
                req.setAttribute("msg","激活成功!<a href=\""+req.getContextPath()+"/shop/client/login.jsp\">点击这里</a>跳转登录");
                req.getRequestDispatcher("/shop/client/tips.jsp").forward(req,resp);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
